import { createRouter, createWebHistory } from 'vue-router'
import examRoutes from './modules/exam'
import basicRoutes from './modules/basic';
import adminRoutes from './modules/admin';

import type { App } from 'vue';
import { consulateHttp, primaryHttp } from '@/axios/index'

export const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  routes: [...examRoutes, ...basicRoutes, ...adminRoutes],
  //滚动行为
  scrollBehavior() {
    return {
      left: 0,
      top: 0,
    }
  },
})
router.beforeEach((to, from, next) => {
  // 取消请求
  consulateHttp.cancelAllRequest()
  primaryHttp.cancelAllRequest()
  next();
});
export function setupRouter(app: App<Element>) {
  app.use(router);
}
